﻿using Demo.Abp.Extension;
using Demo.NotificationManager.Contracts;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
using Volo.Abp.Timing;
using Volo.Abp.VirtualFileSystem;

namespace Demo.NotificationManager.Client;

[DependsOn(typeof(NotificationManagerContractsModule),   
    typeof(AbpHttpClientModule))]

public class NotificationManagerClientModule : AbpModule
{
    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddTransient<AddHeaderHandler>();
        context.Services.AddHttpClient(NotificationManagerRemoteServiceConsts.RemoteServiceName)
            .AddHttpMessageHandler<AddHeaderHandler>();
        
        context.Services.AddHttpClientProxies(
            typeof(NotificationManagerContractsModule).Assembly,
            NotificationManagerRemoteServiceConsts.RemoteServiceName
        );

        Configure<AbpVirtualFileSystemOptions>(options =>
        {
            options.FileSets.AddEmbedded<NotificationManagerClientModule>();
        });
        Configure<AbpClockOptions>(options => { options.Kind = DateTimeKind.Local; });
    }
}